package pl.bigk.utils.lexengines.period;

import java.util.Locale;
import java.util.ResourceBundle;

import pl.bigk.utils.lexengines.LexEngine;
import pl.bigk.utils.lexengines.LexEnginePL;

public class PeriodEnginePLImpl implements PeriodEngine {

    public static final Locale LOCALE_PL = new Locale("PL");
    public static final Locale LOCALE_PL_pl = new Locale("PL", "pl");

    private static ResourceBundle bundle =
    	ResourceBundle.getBundle("pl.bigk.utils.lexengines.period.resources.PeriodEnginePLImpl");

    private static LexEngine lexEngine = new LexEnginePL();
    
    public PeriodEnginePLImpl() {
    	super();
	}
	
    
	public String getText(int period, int frequency) {
		
		String frequencyText = lexEngine.getTextForNumber(frequency);
		String periodText = null;
		
		if (PeriodEngine.PERIOD_DAY == period) {
			switch (frequency) {
			case 1:
				periodText = bundle.getString("day.1");
				break;
			default:
				periodText = bundle.getString("day.n");
				break;
			}
		} else if (PeriodEngine.PERIOD_MONTH== period) {
			switch (frequency) {
			case 1:
				periodText = bundle.getString("month.1");
				break;
			case 2:
			case 3:
			case 4:
				periodText = bundle.getString("month.2");
				break;				
			default:
				periodText = bundle.getString("month.n");
				break;
			}
		} else if (PeriodEngine.PERIOD_YEAR == period) {
			switch (frequency) {
			case 1:
				periodText = bundle.getString("year.1");
				break;
			case 2:
			case 3:
			case 4:
				periodText = bundle.getString("year.2");
				break;				
			default:
				periodText = bundle.getString("year.n");
				break;
			}			
		}
		
		return frequencyText + " " + periodText;
	}	
}
